<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Relate user and group</title>
</head>
<body>
<form action="saveUserGroup.action" method="post">
<input type="hidden" name="user.id" value="${userId}" />
<table>
	<tr>
		<td>Group</td>
		<td>
			<s:iterator value="checkboxList">
				<input type="checkbox" name="checkboxList" value="${id}" />${groupName}<br/>
			</s:iterator>
		</td>
	</tr>
	<tr>
		<td colspan="2"><input type="submit" name="submit" value="Submit" />
		</td>
	</tr>
</table>
</form>
<script>
	function checkbox(){
		var cbox = [];
		<s:iterator value="currentUserGroups">
			cbox.push(${id});
		</s:iterator>
		var cboxlist = document.getElementsByName("checkboxList");
		for(i=0; i<cboxlist.length;i++){
			for(j=0; j<cbox.length;j++){
				if(cboxlist[i].value == cbox[j]){
					cboxlist[i].checked = "true";
				}
			}
		}
	}
	window.onload = checkbox;
</script>
</body>
</html>